<%--
 *  File:   SalesPopWindow.jsp
 *  Desc:	expensetype pop for report page
 *
 *  Date		   Author		  
 *  2011-2-23	  JackYin		  
 *
 *  Copyright (C) 2000 - 2005 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%
  //init param
  String privilegeCode = "ALL";
  String strTableName = "v_salesmansummary";
  String strModuleName = "COM";
  String contextPath = request.getContextPath();
%>
<%@ include file="/inc/CommonHeader.inc" %>
<html>
<head>
<title>OrgPopWindow</title>
<PageFlow:CheckPageFlow pageName="p_salesmansummary"/>

<%
  	Vector  searchresults = (Vector)pageContext.getAttribute("searchresults");
  	if( searchresults == null)
  	{
  		searchresults = new Vector();
  	}
    int totalsize  =  searchresults.size();
 %>
<%@ include file="/inc/CatchError.inc" %>
<%@ include file="/inc/SumDiv.inc" %>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/SummaryDivision.js"></script>
<script language="JavaScript">
<%--  put your custom script here   --%>
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  if(!editform) return;
  editform.action = "SalesPopWindow.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}

function clickRow(obj,idx)
{
  var cform = document.cform;
  cform.id.value = eval('obj.all.id'+idx).value;
}

function page_done(){
   for(var i = 0; i <<%=totalsize%>; i++){  
    if(document.getElementById('userid'+i).checked){
      	if(isEmpty(document.cform.selectedemployeeid.value)){
        	document.cform.selectedemployeeid.value = document.getElementById('userid'+i).value;
      	}else{
      	    document.cform.selectedemployeeid.value = document.cform.selectedemployeeid.value + "," + document.getElementById('userid'+i).value;;
      	}
      
      	if(isEmpty(document.cform.selectedemployeecode.value)){
       		document.cform.selectedemployeecode.value = document.getElementById('employeecode'+i).value;
     	}else{
        	document.cform.selectedemployeecode.value = document.cform.selectedemployeecode.value + "," + document.getElementById('employeecode'+i).value;;
      	}

      	if(isEmpty(document.cform.selectedemployeename.value)){
        	document.cform.selectedemployeename.value = document.getElementById('employeename'+i).value;
      	}else{
        	document.cform.selectedemployeename.value = document.cform.selectedemployeename.value + "," + document.getElementById('employeename'+i).value;;
      	}
      }
   }

   opener.SetSalesMan(document.cform.selectedemployeeid.value,document.cform.selectedemployeecode.value,document.cform.selectedemployeename.value);  
  window.close();
}

function page_close(){
	window.close();
}

function clickCheckBox(obj){
	if(cform.numrows.value == 0){
		cform.selectedids.checked=obj.checked;
	}else if(cform.numrows.value >= 1){
		var j=0;
		for(var i=0;i<Number(cform.numrows.value);i++){
			var idchk=document.getElementById('userid'+j);
			if(idchk){
				idchk.checked=obj.checked;
			}
			j++;
		}
	}
}
function clearCheckFlag(obj){
	if(!obj.checked){
		cform.checkallbox.checked=false;
	}
}
</script>
</head>

<body>
<div id=div2 style="HEIGHT: 415px; OVERFLOW: auto;">
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher">
<input type="hidden" name="pagename" value="p_salesmansummary">
<input type="hidden" name="actionname">  
<input type="hidden" name="numrows" value="<%=totalsize%>">
<custom:hidden property="selectedemployeeid"/> 
<custom:hidden property="selectedemployeecode"/>
<custom:hidden property="selectedemployeename"/>

	<custom:hidden property="regionid"/>
 <custom:hidden property="proviceofficecode"/>
 <custom:hidden property="businessareacode"/>	

 
 
 
 
 
    <table width="100%" cellspacing="0" border="0" cellpadding="0">
      <tr>
<%--  search criteria  --%>
      </tr>
      <tr>
        <td>
          <table width="100%" border="0" cellspacing="0">
            <%@ include file="/inc/SummarySearch.inc" %>
          </table>
        </td>
      </tr>
      <tr>
        <td>
          <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
        <tr class="deepblue-left" >
		  <td width="26" class="title_center">
			<%if(totalsize > 0){ %>
				<input type="checkbox" name="checkallbox" class="checkbox"  onclick="clickCheckBox(this)">
			<%}else{ %>
				&nbsp;
			<%} %>
		  </td>
          <td width="100" class="title_center"><a href="javascript:page_summary('orderby','employeecode')"><%= label.getLabelName("L_Salesmancode") %></a></td>
          <td class="title_center" width="100"><a href="javascript:page_summary('orderby','employeename')"><%= label.getLabelName("L_SalesmanName") %></a></td>
           <td width="100" class="title_center"><a href="javascript:page_summary('orderby','deptname')"><%= label.getLabelName("L_Department") %></a></td>
          <td class="title_center" width="100"><a href="javascript:page_summary('orderby','jobtitlename')"><%= label.getLabelName("L_TitleName") %></a></td>
        </tr>
		 <% //--------------------------------------  default value definition --%>
          	<%
            	int i = 0;
             	String strClassType = new String();
          	%>

          	<% //--------------------------------------  loop results --%>
		<logic:iterate id="onerow" collection="<%=searchresults %>" indexId="idx">
           	<%
            	HashMap tempMap = (HashMap)pageContext.getAttribute("onerow");
           	
            	if(i%2 == 1)
            	{
              		strClassType = "td-listrom";
            	}else{
              		strClassType = "";
            	}
            	i++;
          	%>
          	<tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'"  class="none">
          		<td width="5">
              		<input id="userid<%= idx %>" type="checkbox" name="userid" value="<%=JspHelper.filterNull( tempMap.get("userid") )%>" class="checkbox" onclick="clearCheckFlag(this)">
            	</td>
            	<td>
            
            		<custom:write name="onerow" property="employeecode"/>
            	</td>
            	<td>
            		<custom:write name="onerow" property="employeename"/>
            	</td>
              		<custom:hidden name="onerow" property="employeecode" colIndex="<%= idx %>" />
              		<custom:hidden name="onerow" property="employeename" colIndex="<%= idx %>" />
              		
              		
              		<td>
            		<custom:write name="onerow" property="deptname"/>
            	</td>
            	<td>
            		<custom:write name="onerow" property="jobtitlename"/>
            	</td>
            		<custom:hidden name="onerow" property="deptname" colIndex="<%= idx %>" />
              		<custom:hidden name="onerow" property="jobtitlename" colIndex="<%= idx %>" />
            	
     		 </tr>
     	 </logic:iterate>

            <%@ include file="/inc/SummaryAction.inc" %>
          </table>
          <table width="100%" cellspacing="0" cellpadding="0">
            <tr><td class="summary_top"></td></tr>
            <tr>
              <td class="td_center">
                <a onclick="page_done();"><custom:button type="1" label="L_Ok" imgsrc="add.gif" border="0" style="width:60"/></a>
              	<a onclick="page_close();"><custom:button type="1" label="L_Close" imgsrc="close.gif" border="0" style="width:60"/></a>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
</form>
</div>
</body>
</html>